<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class AccountController extends CUserController
{

	
	public function actionIndex()
	{
		$this->actionUpdateUser();
	}
	
	public function actionChangePasswd(){
		$model = new PasswdModifyForm();
		$modifySuccess = false;
		if(Yii::app()->request->isPostRequest)
		{
			$model->attributes=$_POST['PasswdModifyForm'];
			if($model->save()){
                if (SYSTEM_STATUS == "init") {
                    SystemManager::addUserSuccess();
                } elseif (SYSTEM_STATUS == "done" && $model->passwd == "admin") {
                    SystemManager::delUserSuccess();
                }
								$model->oldPasswd="";
				$model->passwd = "";
				$model->passwdConfirm="";
				$modifySuccess = true;
			}
		}
		$this->render('passwdModify',array(
            'model'         => $model,
		    'modifySuccess' => $modifySuccess
		));
	}
	
	public function actionUpdateUser()
	{
		$id=Yii::app()->session["user"]["id"];
		$model = new UserUpdateForm();
		$model->initData($id);
		$modifySuccess = false;
		if(Yii::app()->request->isPostRequest)
		{
			$model->attributes=$_POST['UserUpdateForm'];
			if($model->save()){				$userBase = new UserBase();
				$userBase->load($id);
				Yii::app()->session["user"]=$userBase->serialize();
				$modifySuccess = true;
			}
		}
		$this->render('updateUser',array(
            'model'         => $model,
		    'modifySuccess' => $modifySuccess
		));
	}


}